import requests

# 评论
header = {"Content-Type": "application/json"}
cookie = {"session": "5e8b820c-9c04-43c0-9340-5509eadb291d.XtNbfRmjun8WFuB5l0K7Yr1p4mY"}
data = '{"news_id": "1", "comment": "小黑子"}'.encode("utf-8")
r = requests.post("http://192.168.41.120:9999/news/news_comment", headers=header, cookies=cookie, data=data)
id = r.json()["data"]["id"]
print(id)

# 回复评论
header = {"Content-Type": "application/json"}
cookie = {"session": "5e8b820c-9c04-43c0-9340-5509eadb291d.XtNbfRmjun8WFuB5l0K7Yr1p4mY"}
data = ('{"news_id": "1", "comment": "ikun你好,露出鸡脚了吧!", "parent_id": "%s"}' % id).encode("utf-8")
r = requests.post("http://192.168.41.120:9999/news/news_comment", headers=header, cookies=cookie, data=data)
print(r.json())
print(r.status_code)
